const sc = new SockJS("/socket");
const stompClient = Stomp.over(sc);
stompClient.debug = null;

const Socket = {
    connect: function (topic, callback) {
        if (stompClient.connected) {
            stompClient.subscribe(topic, callback);
        } else {
            stompClient.connect({}, function () {
                stompClient.subscribe(topic, callback);
            })
        }
    },
    disconnect: function () {
        stompClient.disconnect();
    },
}